import { execSync } from 'child_process';

export const getLastCommitMsg = () => {
    // 获取全部提交信息
    // const lastCommitMsg = exec('git show -s').toString().trim()
    // 获取分支
    const rev = execSync('git rev-parse --abbrev-ref HEAD').toString().trim()
    // 提交的commit hash
    let commitHash = execSync('git show -s --format=%H').toString().trim();
    // 提交人姓名
    let name = execSync('git show -s --format=%cn').toString().trim();
    // 提交日期
    let date = execSync('git show -s --format=%cd').toString();
    // 提交描述
    let message = execSync('git show -s --format=%s').toString().trim();

    return `
        branch: ${rev},
        commitHash: ${commitHash},
        author: ${name},
        commitDate: ${date},
        commitMessage: ${message}
    `
}